/*****************************************************************************
 * Copyright (C) Stacy Curl. All rights reserved.                            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/
package picounit.features.ruby_string.delayed;

import moved.org.objectweb.asm.Label;
import moved.org.objectweb.asm.MethodVisitor;

public class LineNumberInstruction extends AbstractMethodInstruction {
	private final int line;
	private final Label startLabel;

	public LineNumberInstruction(int line, Label startLabel) {
		this.line = line;
		this.startLabel = startLabel;
	}
	
	///////////////////////////////////////////////////////////////////////////////////////////////
	// MethodInstruction Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	public void accept(MethodVisitor methodVisitor) {
		methodVisitor.visitLineNumber(line, startLabel);
	}

	///////////////////////////////////////////////////////////////////////////////////////////////
	// Object Methods
	///////////////////////////////////////////////////////////////////////////////////////////////

	@Override
	public boolean equals(Object object) {
		if (object == null || !(object.getClass().equals(getClass()))) {
			return false;
		}

		LineNumberInstruction other = (LineNumberInstruction) object;

		return line == other.line &&
			startLabel.equals(other.startLabel);
	}
}
